import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/12 20:36
 */

public class Solution {
    int left, right, m;
    StringBuffer path;
    List<String> ret;

    public List<String> generateParenthesis(int n) {
        m = n;
        path = new StringBuffer();
        ret = new ArrayList<>();
        dfs();
        return ret;
    }

    public void dfs() {
        // 当右括号数量等于m时，表示已经完成了一个合法的组合
        if (right == m) {
            ret.add(path.toString());
            return;
        }

        // 如果左括号数量小于m，添加左括号
        if (left < m) {
            path.append('(');
            left++;
            dfs();
            // 回溯
            path.deleteCharAt(path.length() - 1);
            left--;
        }

        // 如果右括号数量小于左括号数量，可以添加右括号
        if (right < left) {
            path.append(')');
            right++;
            dfs();
            // 回溯
            path.deleteCharAt(path.length() - 1);
            right--;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            Solution solution = new Solution();
            System.out.println(solution.generateParenthesis(n));
        }
    }
}